<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of UploadCallback
 *
 * @author admin
 */

namespace FlowCharge;

class UploadCallback implements \Payment\Notify\PayNotifyInterface {

    public function notifyProcess(array $data) {
        $this->uploadXml($data['out_trade_no']);
    }

    private function uploadXml($out_trade_no) {
        $xmlData = "
			<xml>
			 <out_trade_no><![CDATA[{$out_trade_no}]]></out_trade_no>
			</xml>";
        $url = "http://120.25.126.95:8033/cms/order/pay/payNotify3.do";
        $header[] = "Content-type: text/xml";
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlData);
        $response = curl_exec($ch);
        if (curl_errno($ch)) {
            print curl_error($ch);
        }
        curl_close($ch);

        return $response;
    }

//put your code here
}
